
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="http://img.mukewang.com/down/540812440001e40e00000000.js" type="text/javascript"></script>
<!-- <script type="text/javascript" src="../jquery-2.1.1.js"></script> -->
<title></title>
</head>
<body>


<button id="test1">模拟编译原理,点击选中checked</button>

<div id="text">
  <div class="Aaron">
     <input type="checkbox" name="readme" />
     <input type="checkbox" name="ttt" />
     <input type="checkbox" name="aaa" />
     <p>Sizzle</p>
  </div>
</div>


<script type="text/javascript">


var match = [{
        matches: ["div"],
        type: "TAG",
        value: "Aaron"
}, {
        type: " ",
        value: " "
}, {
        matches: ["name", "=", "ttt"],
        type: "ATTR",
        value: "[name=ttt]"
}]

Expr.filter = {
    ATTR   : function (name, operator, check) {
    CHILD  : function (type, what, argument, first, last) {
    CLASS  : function (className) {
    ID     : function (id) {
    PSEUDO : function (pseudo, argument) {
    TAG    : function (nodeNameSelector) {
}

function elementMatcher(matchers) {
        //生成一个终极匹配器
        return matchers.length > 1 ?
        //如果是多个匹配器的情况，那么就需要elem符合全部匹配器规则
            function(elem, context, xml) {
                var i = matchers.length;
                //从右到左开始匹配
                while (i--) {
                    //如果有一个没匹配中，那就说明该节点elem不符合规则
                    if (!matchers[i](elem, context, xml)) {
                        return false;
                    }
                }
                return true;
        } :
        //单个匹配器的话就返回自己即可
            matchers[0];
    }




</script> 

</body>
</html>









